#include <stdlib.h>
#include <stdio.h>

int main(int argc, char** argv)
{
	FILE* f;
	void* data;
	unsigned int fileSize;
	unsigned int i;
	FILE* out = stdout;

	if (argc != 3 && argc != 4)
		return 0;

	if (argc == 4)
		out = fopen(argv[3], "w");

	f = fopen(argv[1], "r");

	// Get file size
	fseek(f, 0, SEEK_END);
	fileSize = ftell(f);
	rewind(f);

	// Get the data
	data = malloc(fileSize);
	fread(data, fileSize, 1, f);

	fprintf(out, "#pragma once\n\nstatic const unsigned char %s[] = {", argv[2]);
	for (i = 0; i < fileSize; ++i)
	{
		fprintf(out, ((i + 1) == fileSize ? "0x%X" : "0x%X, "), ((unsigned char*)data)[i]);
	}
	fprintf(out, "};\n");

	free(data);
	fclose(f);
	
	if (argc == 4)
		fclose(out);
	else
		system("pause");
}